package com.examples.redis.writer;

import org.apache.flink.api.common.functions.FlatMapFunction;
import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.util.Collector;

public class LineSplitter implements FlatMapFunction<String, Tuple2<String,String>> {
    public void flatMap(String s, Collector<Tuple2<String, String>> collector) throws Exception {
        String[] tokens = s.toLowerCase().split("\\W+");
//        for(String token : tokens){
//            if(token.length() > 0){
//                collector.collect(new Tuple2<String,Integer>(token,1));
//            }
//        }
        collector.collect(new Tuple2<String,String>(tokens[0], s.substring(tokens.length)));
    }
}
